﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BusinessObjects;
using System.Collections;
using DevExpress.XtraGrid.Views.Grid;


namespace QuanLyTruong
{
    public partial class frmQLTieuChiThiDua : DevExpress.XtraEditors.XtraForm
    {
        public bool DaLuu = true;
        List<TieuChiThiDua> listTCTD = new List<TieuChiThiDua>();

        public frmQLTieuChiThiDua()
        {
            InitializeComponent();
        }

        private void frmQLTieuChiThiDua_Load(object sender, EventArgs e)
        {
            GetDSTieuChiThiDua();
        }

        public void GetDSTieuChiThiDua()
        {

            listTCTD = new TieuChiThiDua().TieuChiThiDuaAll();

            grTieuChiThiDua.DataSource = listTCTD;

        }


        private void gv_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            DaLuu = false;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            if (!DaLuu)
            {
                if (XtraMessageBox.Show("Bạn có muốn lưu lại những thay đổi không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                {
                    //ThucHienLuu();
                }
            }
            this.Close();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (!DaLuu)
            {
                DataRow[] CacDongCapNhat;
                DataRow[] CacDongThem;
                ArrayList DanhSachCapNhat = new ArrayList();
                ArrayList DanhSachThem = new ArrayList();

                //CacDongCapNhat = listTCTD.Select(null, null, DataViewRowState.ModifiedCurrent);

                TieuChiThiDua tctd = new TieuChiThiDua();
                tctd.TenTieuChi = "Đi dạy đúng giờ";
                tctd.ThangDiem = 20;
                tctd.SuDung = true;
                tctd.Create();
            }
        }

        private void tabQLThiDua_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            int sel = tabQLThiDua.SelectedTabPageIndex;
            
        }


        
    }
}